<?php

/**
 *
   * Copyright © 2010 Jack Cleaver
   * 
   * This plugin provides functionality added by CalDAV (RFC 4791)
   * It implements new reports, and the MKCALENDAR method.
   *
   * This file is part of Slash.
   *
   * Slash is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * Slash is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with Slash.  If not, see <http://www.gnu.org/licenses/>.
 */
class Slash_ACL_Property_CurrentUserPrivilegeSet extends Sabre_DAV_Property
{

	/**
	 * Serializes the property in a DOMDocument
	 *
	 * @param Sabre_DAV_Server $server
	 * @param DOMElement $node
	 * @return void
	 */
	private $privileges;

	public function __construct($privileges)
	{
		$this->privileges = $privileges;
	}


	public function getPrivileges()
	{
		return $this->privileges;
	}

	
	public function serialize(Sabre_DAV_Server $server,DOMElement $cupsElement)
	{
		$prefix = $server->xmlNamespaces['DAV:'];
    $doc = $cupsElement->ownerDocument;
		
		foreach ($this->privileges as $privName)
		{
			$privElement = $doc->createElement("$prefix:privilege");
			$privilege = $doc->createElement("$prefix:$privName");
			$privElement->appendChild($privilege);
			$cupsElement->appendChild($privElement);
		}
	}

}
